/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.cgb.portal.bean;

import br.cgb.portal.bo.UserBO;
import br.cgb.portal.entity.User;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author LUCAS
 */
@ManagedBean
@SessionScoped
public class SessionBean extends AppBaseBean {

    @EJB
    private UserBO userBO;
    private User user;
    private boolean logged;

    /** Creates a new instance of SessionBean */
    public SessionBean() {
    }

    public void log() {
        if (userBO.authenticateUser(user)){
            user = userBO.findUserPerEmail(user.getEmail());
            logged = true;
        }
    }

    /*
     * Getters and setters
     */
    public User getUser() {
        return (user == null)? user = new User() : user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public boolean isLogged() {
        return logged;
    }

    public void setLogged(boolean logged) {
        this.logged = logged;
    }
}
